// * Echarts 按需引入
import * as echarts from "echarts/core";
import {
  // 柱状图
  BarChart,
  BarSeriesOption,
  // 折线图
  LineChart,
  LineSeriesOption
} from "echarts/charts";
import {
  // 标题
  TitleComponent,
  TitleComponentOption,
  // 图例
  LegendComponent,
  LegendComponentOption,
  // Tooltip
  TooltipComponent,
  TooltipComponentOption,
  // 坐标系网格
  GridComponent,
  GridComponentOption,
  // 数据集组件
  DatasetComponent,
  DatasetComponentOption,
  // 内置数据转换器组件 (filter, sort)
  TransformComponent,
  // 区域缩放
  DataZoomComponent,
  DataZoomInsideComponent,
  DataZoomSliderComponent,
  DataZoomComponentOption,
  // 工具栏
  ToolboxComponent,
  ToolboxComponentOption
} from "echarts/components";
import { LabelLayout, UniversalTransition } from "echarts/features";
import { CanvasRenderer } from "echarts/renderers";

// 通过 ComposeOption 来组合出一个只有必须组件和图表的 Option 类型
export type EChartsOption = echarts.ComposeOption<
  | BarSeriesOption
  | LineSeriesOption
  | TitleComponentOption
  | LegendComponentOption
  | TooltipComponentOption
  | GridComponentOption
  | DatasetComponentOption
  | DataZoomComponentOption
  | ToolboxComponentOption
>;

// 注册必须的组件
echarts.use([
  LegendComponent,
  TitleComponent,
  TooltipComponent,
  GridComponent,
  DatasetComponent,
  TransformComponent,
  DataZoomComponent,
  DataZoomInsideComponent,
  DataZoomSliderComponent,
  ToolboxComponent,
  BarChart,
  LineChart,
  LabelLayout,
  UniversalTransition,
  CanvasRenderer
]);

export default echarts;
